package com.whopxx.biz.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whopxx.biz.HeroBizService;
import com.whopxx.domain.dto.HeroPageDTO;
import com.whopxx.domain.entity.Hero;
import com.whopxx.domain.vo.BasePageVO;
import com.whopxx.domain.vo.HeroPageVO;
import com.whopxx.service.HeroService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HeroBizServiceImpl implements HeroBizService {
    @Resource
    private HeroService heroService;

    @Override
    public BasePageVO<HeroPageVO> page(HeroPageDTO dto) {
        Page<Hero> page = heroService.pageQuery(dto);
        BasePageVO<HeroPageVO> result =  BasePageVO.convert(page, e -> {
            HeroPageVO vo = new HeroPageVO();
            vo.setId(e.getId());
            vo.setName(e.getName());
            vo.setImgFileId(e.getImgFileId());
            return vo;
        });
        return result;
    }
}
